#include "mainwidget.h"
#include "ui_mainwidget.h"

#define SHOWTYPE 0   //0为使用QWidget显示，1为使用OpenGL显示

MainWidget::MainWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::MainWidget)
{
    ui->setupUi(this);

#if SHOWTYPE
    mOpebGlWidget = new I420Render;
    QVBoxLayout *tHLayout = new QVBoxLayout(ui->frame2);
    tHLayout->setMargin(0);
    tHLayout->setSpacing(0);
    tHLayout->setContentsMargins(0,0,0,0);
    tHLayout->addWidget(mOpebGlWidget);
#else
    mPlayWidget = new PlayWidget(this);
    QVBoxLayout *tHLayout = new QVBoxLayout(ui->frame2);
    tHLayout->setMargin(0);
    tHLayout->setSpacing(0);
    tHLayout->setContentsMargins(0,0,0,0);
    tHLayout->addWidget(mPlayWidget);
#endif
}

MainWidget::~MainWidget()
{
    delete ui;
}

void MainWidget::on_btnPlay_clicked()
{
    QString urlStr = ui->lineUrl->text().trimmed();

#if SHOWTYPE
    mOpebGlWidget->set_url(urlStr);
    mOpebGlWidget->play();
#else
    mPlayWidget->set_url(urlStr);
    mPlayWidget->play();
#endif
}

void MainWidget::on_btnStop_clicked()
{
#if SHOWTYPE
    mOpebGlWidget->stop();
#else
    mPlayWidget->stop();
#endif
}
